﻿using System;
using System.Collections.Generic;
using NetBay.Core.Log;
using Rio.Manager.Business.Repository.Translator;
using NetBay.Core.BusinessEntities.TaskManager;
using Rio.Manager.DataAccess;

namespace Rio.Manager.Business.Repository
{
    public class TaskManagerRepository
    {
        /// <summary>
        /// Get RIO's task manager. 
        /// </summary>
        /// <returns></returns> 
        public static List<TaskItem> GetTaskManager()
        {
            return TaskManagerTranslator.GetTaskManager(DA_TaskManager.GetTaskManager());
        }

        /// <summary>
        /// Add a new task Manager.
        /// </summary>
        /// <param name="p_oTaskToAdd">Task to add</param>
        /// <returns></returns>
        public static void AddTaskManager(TaskItem p_oTaskToAdd)
        {
            try
            {
                DA_TaskManager.AddTaskManager(p_oTaskToAdd);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError(ex.Message);
            }
        }

        /// <summary>
        /// Delete RIO's task manager list. 
        /// </summary>
        /// <param name="p_oTaskToDelete">Task to delete</param>
        /// <returns></returns> 
        public static void DeleteTaskManager(TaskItem p_oTaskToDelete)
        {
            try
            {
                DA_TaskManager.DeleteTaskManager(p_oTaskToDelete);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError(ex.Message);
            }
        }

        /// <summary>
        ///Delete all RIO's task manager. 
        /// </summary>
        /// <param name="p_oTaskToDelete">Delete all the task</param>
        /// <returns></returns> 
        public static void DeleteAllTaskManager()
        {
            try
            {
                DA_TaskManager.DeleteAllTaskManager();
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError(ex.Message);
            }
        }

        /// <summary>
        /// Update RIO's task manager list. 
        /// </summary>
        /// <param name="p_oTaskToUpdate">Task to update</param>
        /// <param name="p_sOldAction">Old action value if it's modify</param>
        /// <param name="p_sOldStartHour">Old start hour if it's modify</param> 
        /// <returns></returns> 
        public static void UpdateTaskManager(TaskItem p_oTaskToUpdate, string p_sOldAction, string p_sOldStartHour)
        {
            try
            {
                DA_TaskManager.UpdateTaskManager(p_oTaskToUpdate, p_sOldAction, p_sOldStartHour);
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogError(ex.Message);
            }
        }
    }
}